﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using myBoard.Framework.Controls.Navigation;
using myTwitter.CutomControls;
using System.Windows;
using System.ComponentModel;
using myBoard.Framework;

namespace myTwitter.BO
{
    public class Users : ObservableCollection<User>, IBreadcrumbExplorerEntity
    {
        UsersNavigator _usersNavigator;

        public Users()
        { }
        public Users(IEnumerable<User> list)
            : base(list)
        { }

        #region IBreadcrumbExplorerEntity Members

        public string Name {get;set;}

        public System.Windows.Media.Imaging.BitmapImage Icon { get; set; }

        public System.Windows.FrameworkElement GetControl()
        {
            _usersNavigator = new UsersNavigator();
            _usersNavigator.UserInfoRequested += _usersNavigator_UserInfoRequested;
            _usersNavigator.DataContext = this;
            _usersNavigator._titleTxb.Text = Name;
            return _usersNavigator;
        }

        void _usersNavigator_UserInfoRequested(User user)
        {
            if (IBreadcrumbExplorerNextEntitySelected != null)
                IBreadcrumbExplorerNextEntitySelected(this, user);                       
        }

        public void Dispose()
        {
            _usersNavigator.UserInfoRequested -= _usersNavigator_UserInfoRequested;
        }

        public void Update(object newValue)
        { }

        public event IBreadcrumbExplorerNextEntitySelectedHandler IBreadcrumbExplorerNextEntitySelected;

        #endregion
    }
}
